/* Rust智能助手界面样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --robot-primary: #1e88e5;
    --robot-secondary: #43a047;
    --robot-accent: #f44336;
    --robot-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --robot-card: rgba(255, 255, 255, 0.95);
    --robot-text: #2c3e50;
    --robot-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--robot-bg);
    min-height: 100vh;
    overflow-x: hidden;
}

.robot-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 顶部导航栏 */
.robot-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 100;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.nav-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.welcome-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.welcome-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.welcome-label {
    font-size: 0.85rem;
}

.tts-toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tts-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.tts-toggle-btn.active {
    background: rgba(67, 160, 71, 0.3);
    border-color: rgba(67, 160, 71, 0.5);
}

.tts-toggle-btn.active i {
    color: #4caf50;
    animation: pulse-sound 2s ease-in-out infinite;
}

@keyframes pulse-sound {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.tts-label {
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .tts-label,
    .welcome-label {
        display: none;
    }
    
    .tts-toggle-btn,
    .welcome-btn {
        padding: 8px 12px;
    }
}

/* 主内容区域 */
.robot-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
    gap: 30px;
}

/* 机器人形象区域 */
.robot-avatar-section {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
}

.robot-avatar-container {
    text-align: center;
    position: relative;
}

.robot-avatar {
    position: relative;
    display: inline-block;
    width: 200px;
    height: 200px;
    margin-bottom: 20px;
}

.crab-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.3));
    animation: float 3s ease-in-out infinite;
    z-index: 10;
    position: relative;
}

.crab-emoji-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: float 3s ease-in-out infinite;
    z-index: 10;
    position: relative;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.3));
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* 脉冲环效果 */
.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    margin: -100px 0 0 -100px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: pulse 2s ease-out infinite;
    opacity: 0;
}

.pulse-ring.delay-1 {
    animation-delay: 0.5s;
}

.pulse-ring.delay-2 {
    animation-delay: 1s;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.robot-status {
    margin-top: 20px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    display: inline-block;
}

.status-text {
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
}

.robot-status.listening .status-text::before {
    content: '🔴 ';
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* 开始对话按钮 */
.start-chat-section {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease;
}

.start-chat-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 200% 200%;
    color: white;
    border: none;
    border-radius: 50px;
    padding: 18px 40px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.4), 0 0 0 0 rgba(102, 126, 234, 0.7);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
    animation: gradientShift 3s ease infinite, floatBtn 3s ease-in-out infinite;
    z-index: 10;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes floatBtn {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

.start-chat-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.start-chat-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.start-chat-btn:hover {
    background: linear-gradient(135deg, #f093fb 0%, #764ba2 50%, #667eea 100%);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.6), 0 0 0 10px rgba(102, 126, 234, 0.1);
    transform: translateY(-5px) scale(1.05);
    animation: none;
    background-position: 100% 50%;
}

.start-chat-btn:hover::before {
    width: 400px;
    height: 400px;
}

.start-chat-btn:active {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5);
}

.start-chat-btn i {
    font-size: 1.3rem;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    animation: rotateIcon 2s ease-in-out infinite;
}

@keyframes rotateIcon {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

.start-chat-btn:hover i {
    transform: rotate(360deg) scale(1.2);
    animation: none;
}

.start-chat-btn span {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.start-chat-btn.clicked {
    animation: buttonClick 0.5s ease;
}

@keyframes buttonClick {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@media (max-width: 768px) {
    .start-chat-section {
        margin-top: 20px;
    }
    
    .start-chat-btn {
        padding: 14px 30px;
        font-size: 1rem;
        width: auto;
        min-width: 200px;
    }
    
    .start-chat-btn span {
        font-size: 1rem;
    }
    
    .start-chat-btn i {
        font-size: 1.1rem;
    }
}

/* 对话区域 */
.robot-chat-section {
    flex: 1;
    background: var(--robot-card);
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--robot-shadow);
    overflow-y: auto;
    max-height: 400px;
    min-height: 300px;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    display: flex;
    gap: 12px;
    max-width: 70%;
    align-items: flex-start;
}

.message.user .message-content {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.robot-message .message-avatar {
    background: linear-gradient(135deg, var(--robot-primary), var(--robot-secondary));
    color: white;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: white;
}

.message-text {
    background: #f5f5f5;
    padding: 15px 20px;
    border-radius: 18px;
    line-height: 1.6;
    color: var(--robot-text);
}

.robot-message .message-text {
    background: linear-gradient(135deg, #e3f2fd, #f3e5f5);
    border-top-left-radius: 4px;
}

.user-message .message-text {
    background: linear-gradient(135deg, #fff3e0, #fce4ec);
    border-top-right-radius: 4px;
}

.message-text p {
    margin-bottom: 10px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text ul {
    margin-left: 20px;
    margin-top: 10px;
}

.message-text li {
    margin-bottom: 5px;
}

.message-text h1, .message-text h2, .message-text h3 {
    margin: 15px 0 10px 0;
    color: var(--robot-text);
}

.message-text h1 {
    font-size: 1.5rem;
    border-bottom: 2px solid var(--robot-primary);
    padding-bottom: 5px;
}

.message-text h2 {
    font-size: 1.3rem;
}

.message-text h3 {
    font-size: 1.1rem;
}

.message-text code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #e83e8c;
}

.message-text pre {
    background: #282c34;
    color: #abb2bf;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.5;
}

.message-text pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.message-text strong {
    color: var(--robot-primary);
    font-weight: 600;
}

.message-text em {
    font-style: italic;
    color: #666;
}

/* 输入区域 */
.robot-input-section {
    background: var(--robot-card);
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--robot-shadow);
}

/* 内联输入区域（在对话区域内部） */
.robot-input-section-inline {
    margin-top: 20px;
    padding: 20px;
    border-top: 2px solid #e0e0e0;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 0 0 20px 20px;
}

.input-wrapper {
    display: flex;
    gap: 15px;
    align-items: center;
}

.voice-input-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--robot-secondary), #66bb6a);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.voice-input-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(67, 160, 71, 0.4);
}

.voice-input-btn.recording {
    background: linear-gradient(135deg, var(--robot-accent), #e53935);
    animation: pulse-btn 1.5s ease-in-out infinite;
}

@keyframes pulse-btn {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.7);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(244, 67, 54, 0);
    }
}

.robot-input {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.robot-input:focus {
    border-color: var(--robot-primary);
    box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.1);
}

.robot-input::placeholder {
    color: #999;
}

.send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--robot-primary), #42a5f5);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(30, 136, 229, 0.4);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.input-hint {
    margin-top: 12px;
    text-align: center;
    color: #666;
    font-size: 0.85rem;
}

/* 加载指示器 */
.loading-indicator {
    position: fixed;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

.loading-dots {
    display: flex;
    gap: 8px;
    background: var(--robot-card);
    padding: 15px 25px;
    border-radius: 25px;
    box-shadow: var(--robot-shadow);
}

.loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--robot-primary);
    animation: bounce 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .robot-nav {
        padding: 15px 20px;
    }

    .nav-title {
        font-size: 1.2rem;
    }

    .robot-main {
        padding: 20px 15px;
    }

    .robot-avatar {
        width: 150px;
        height: 150px;
    }

    .crab-image {
        width: 100%;
        height: 100%;
    }

    .robot-chat-section {
        padding: 20px;
        max-height: 300px;
    }

    .message-content {
        max-width: 85%;
    }

    .input-wrapper {
        gap: 10px;
    }

    .voice-input-btn,
    .send-btn {
        width: 45px;
        height: 45px;
    }
}

/* 滚动条样式 */
.robot-chat-section::-webkit-scrollbar {
    width: 6px;
}

.robot-chat-section::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.robot-chat-section::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.robot-chat-section::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 浮动输入框样式 */
.floating-input-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.floating-input-wrapper {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    animation: scaleIn 0.3s ease;
    overflow: hidden;
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.floating-input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.floating-input-header span {
    font-size: 1.1rem;
    font-weight: 600;
}

.floating-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.floating-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.floating-input-body {
    padding: 25px;
}

.floating-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    min-height: 80px;
    max-height: 200px;
    overflow-y: auto;
}

.floating-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.floating-input::placeholder {
    color: #999;
}

.floating-input-footer {
    display: flex;
    gap: 15px;
    padding: 20px 25px;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.floating-voice-btn,
.floating-send-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.floating-voice-btn {
    background: linear-gradient(135deg, #43a047, #66bb6a);
    color: white;
}

.floating-voice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(67, 160, 71, 0.3);
}

.floating-voice-btn.recording {
    background: linear-gradient(135deg, #f44336, #e53935);
    animation: pulse-btn 1.5s ease-in-out infinite;
}

.floating-send-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.floating-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.floating-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 768px) {
    .floating-input-wrapper {
        width: 95%;
    }
    
    .floating-input-header {
        padding: 15px 20px;
    }
    
    .floating-input-body {
        padding: 20px;
    }
    
    .floating-input-footer {
        padding: 15px 20px;
        flex-direction: column;
    }
    
    .floating-voice-btn,
    .floating-send-btn {
        width: 100%;
    }
}

